# include "Player.h"

Player::Player() {
	pos = 0;
	friction = 0;

	rect.left = 0;	// Top left X
	rect.top =	0; // Top left y
	rect.bottom = 32;					// Bottom right y
	rect.right = 32; // Bottom right x
	
	once = false;
}
Player::~Player() {

}

void Player::Init(HWND& hWnd, HINSTANCE& hInst) {
	ga.Create("Images/ColorfulCircle_SpriteSheet.png", D3DXVECTOR3(32, 32, 0), D3DXVECTOR3(1, 1, 0), 0.0f);
	//ms.Init(hWnd, hInst);
	kb.Init(hWnd, hInst);
}
void Player::Input() {

}
void Player::Update() {
	//ms.Update();
	ExecuteKeboardUpdate();
}
void Player::ExecuteKeboardUpdate() {
	kb.Update();
	D3DXVECTOR3 a_Value = ga.getPos();
	if(kb.buffer[DIK_W] & 0x80) {
		a_Value.y -= velocity;
		ga.setPos(a_Value);
	}
	if(kb.buffer[DIK_A] & 0x80) {
		a_Value.x -= velocity;
		ga.setPos(a_Value);
	}
	if(kb.buffer[DIK_S] & 0x80) {
		a_Value.y += velocity;
		ga.setPos(a_Value);
	}
	if(kb.buffer[DIK_D] & 0x80) {
		a_Value.x += velocity;
		ga.setPos(a_Value);
	}
	if(kb.buffer[DIK_SPACE] & 0x80 && once == false) {
		if(rect.right < ga.getInfo().Width) {
			rect.left	+= 32;	// -X
			rect.top	+= 0;	// +Y

			rect.right	+= 32;	// +X
			rect.bottom += 0;	// -Y
			once = true;
		}
		else {
			rect.left = 0;		// Top left X
			rect.top =	0;		// Top left y
			rect.bottom = 32;	// Bottom right y
			rect.right = 32;	// Bottom right x
			once = true;
		}
	}
	if(!kb.buffer[DIK_SPACE]) {
		once = false;
	}
}
void Player::Render() {
	//ms.Render();
	
	ga.Draw(rect);

}
void Player::Release() {
	ga.Shutdown();
	//ms.Release();
	kb.Release();
}